package com.lantu.draw.svgimg.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lantu.draw.svgimg.mapper.SVGPaintIconMapper;
import com.lantu.draw.svgimg.mapper.SVGPaintMapper;
import com.lantu.draw.svgimg.vo.SVGPaintIconVO;
import com.lantu.draw.svgimg.vo.SVGPaintVO;


@Service
public class SVGImageServiceImpl implements SVGImageService {
	@Autowired
	SVGPaintMapper paintMapper;
	@Autowired
	SVGPaintIconMapper iconMapper;
	public int savesvg(SVGPaintVO vo){
		return  paintMapper.savesvg(vo);
	}
	@Override
	public int saveIcon(SVGPaintIconVO vo) {
		return   iconMapper.save(vo);
	}
	@Override
	public List<SVGPaintVO> queryPaintByUsrId(String usrId,SVGPaintVO qo) {
		//SVGPaintVO qo=new SVGPaintVO();
		qo.setUsrId(usrId);
		return paintMapper.queryList(qo);
	}

	public List<SVGPaintIconVO> queryIconByUsrId(String usrId) {
		SVGPaintIconVO qo=new SVGPaintIconVO();
		qo.setUsrId(usrId);
		return iconMapper.queryList(qo);
	}
	@Override
	public SVGPaintVO queryPaintByPaintId(Integer paintId) {
		return paintMapper.queryPaintByPaintId(paintId);
	}
	@Override
	public List<SVGPaintIconVO> queryShareIcon(SVGPaintIconVO qo){
		return iconMapper.queryShareIcon(qo);
	}
	@Override
	public List<SVGPaintIconVO> queryIconByUsrId(String usrId, SVGPaintIconVO qo) {
		return iconMapper.queryList(qo);
	}
	@Override
	public List<SVGPaintIconVO> queryIconByUsrId(SVGPaintIconVO qo) {
		return iconMapper.queryList(qo);
		
	}
	@Override
	public boolean isHasAuth(String url, String idcard) {
		System.out.println(url.replace("/paint/", "")+","+idcard);
		SVGPaintVO qo=new SVGPaintVO();
		qo.setIdcard(idcard);
		qo.setFileName(url.replace("/paint/", ""));
		int ttl=paintMapper.queryCountByIdcardAndImgurl(qo);
		if(ttl>0){
			return true;
		}
		return false;
	}
}
